<template>
  <div class="page-component">
    <h3>代码块模板</h3>
    <div class="demo_block"  @mouseover="hover=true" @mouseleave="hover=false">
      <div class="source">
        <div>
          <el-row :gutter="20">
            <el-col :span="6">
              <div class="grid-content bg-purple"></div>
            </el-col>
            <el-col :span="6">
              <div class="grid-content bg-purple"></div>
            </el-col>
            <el-col :span="6">
              <div class="grid-content bg-purple"></div>
            </el-col>
            <el-col :span="6">
              <div class="grid-content bg-purple"></div>
            </el-col>
          </el-row>
        </div>
      </div>
      <div class="meta" :class="{meta_height:!isActive}">
        <div class="description">
          <div><p>通过 row 和 col 组件，并通过 col 组件的 <code>span</code> 属性我们就可以自由地组合布局。</p></div>
        </div>
        <div v-highlight>
          <pre><code>&lt;el-row :gutter=&quot;20&quot;&gt;
  &lt;el-col :span=&quot;6&quot;&gt;&lt;div class=&quot;grid-content bg-purple&quot;&gt;&lt;/div&gt;&lt;/el-col&gt;
  &lt;el-col :span=&quot;6&quot;&gt;&lt;div class=&quot;grid-content bg-purple&quot;&gt;&lt;/div&gt;&lt;/el-col&gt;
  &lt;el-col :span=&quot;6&quot;&gt;&lt;div class=&quot;grid-content bg-purple&quot;&gt;&lt;/div&gt;&lt;/el-col&gt;
  &lt;el-col :span=&quot;6&quot;&gt;&lt;div class=&quot;grid-content bg-purple&quot;&gt;&lt;/div&gt;&lt;/el-col&gt;
&lt;/el-row&gt;

&lt;style&gt;
  .el-row {
    margin-bottom: 20px;
    &amp;:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
&lt;/style&gt;</code></pre>
        </div>
      </div>
      <div class="demo_block_control" :class="{is_fixed:isActive}" @click="demo_click" :style="demoBlockObject">
        <i class="el-icon-caret-top"></i>
        <span v-if="hover">{{button_value}}</span>
      </div>
    </div>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
    <h3>代码块模板</h3>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        demoBlockObject:{

        },
        hover: true,
        button_value: '打开代码',
        isActive: false,
        styleObject: {
          color: 'red',
          fontSize: '30px'
        }
      }
    },
    computed: {},
    methods: {
      //true为隐藏,false为打开
      demo_click () {
        //点击隐藏代码
        if (this.isActive) {//true
          this.isActive = false
          this.button_value = '打开代码'
        } else {
          this.isActive = true
          this.button_value = '隐藏代码'
        }
        console.log(this.isActive)
      },
      testclick () {
        if (this.isActive) {
          this.isActive = false
          this.styleObject.color = 'black'
        } else {
          this.isActive = true
          this.styleObject.color = 'red'
        }

        console.log(this.styleObject.color)
      }
    }
  }
</script>

<style scoped>
  .demo_block {
    margin-bottom: 24px;
    border: 1px solid #ebebeb;
    border-radius: 3px;
    transition: .2s;
    /*background-color: pink;*/
  }
  .demo_block .source {
    padding: 24px;
  }
  .demo_block .meta {
    background-color: #fafafa;
    border-top: 1px solid #eaeefb;
    overflow: hidden;
    /*height: 0;*/
    transition: height .2s;
  }
  .demo_block .meta_height{
    height: 0px;
  }
  .demo_block .description {
    padding: 20px;
    box-sizing: border-box;
    border: 1px solid #ebebeb;
    border-radius: 3px;
    font-size: 14px;
    line-height: 22px;
    color: #666;
    word-break: break-word;
    margin: 10px;
    background-color: #fff;
  }
  .demo_block .demo_block_control {
    border-top: 1px solid #eaeefb;
    height: 44px;
    box-sizing: border-box;
    background-color: #fff;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    text-align: center;
    margin-top: -1px;
    color: #d3dce6;
    cursor: pointer;
    /*position: relative;*/
    /*false隐藏 relative,true显示 */
  }
  .demo_block .demo_block_control.is_fixed {
    position: fixed;
    bottom: 0;
    width: 868px;
  }
  /*其他样式*/
  .el-row {
    margin-bottom: 20px;

  &
  :last-child {
    margin-bottom: 0;
  }

  }
  .el-col {
    border-radius: 4px;
  }

  .bg-purple-dark {
    background: #99a9bf;
  }

  .bg-purple {
    background: #d3dce6;
  }

  .bg-purple-light {
    background: #e5e9f2;
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
